package com.domino.server.persistence;

import javax.management.RuntimeErrorException;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;

public final class EMF {
    private static final EntityManagerFactory emfInstance =
        Persistence.createEntityManagerFactory("transactions-optional");

    private EMF() {}

    public static EntityManager create() {
    	EntityManager em = get().createEntityManager();
    	if (em==null) {
    		throw new RuntimeException("Failed to create entity manager");
    	}
    	return em;
    }
    private static EntityManagerFactory get() {
        return emfInstance;
    }
}
